#!/bin/bash
单个节点重启后需要启动下列服务

rabbitmq-server -detached
systemctl start mariadb
netstat -anpo|grep 3306

netstat -antp|grep '5672'


#关闭群集后，重启
#在其中一台
sed -i 's#seqno: -1#seqno: 1#' /var/lib/mysql/grastate.dat
galera_new_cluster #启动第一个节点
#其它节点
systemctl start mariadb

#检查Mariadb集群
DBPass=innobase
mysql -u root -p$DBPass -e "show status like 'wsrep_cluster_size';"
mysql -u root -p$DBPass -e "show status like 'wsrep_incoming_addresses';"


# 服务器重启后，下面的服务需要在mariadb集群后重启

systemctl status openstack-nova-api.service \
  openstack-nova-consoleauth.service openstack-nova-scheduler.service \
  openstack-nova-conductor.service openstack-nova-novncproxy.service

systemctl restart openstack-nova-api.service \
  openstack-nova-consoleauth.service openstack-nova-scheduler.service \
  openstack-nova-conductor.service openstack-nova-novncproxy.service

systemctl stop openstack-nova-api.service \
  openstack-nova-consoleauth.service openstack-nova-scheduler.service \
  openstack-nova-conductor.service openstack-nova-novncproxy.service

systemctl stop mariadb

systemctl start openstack-nova-api.service \
  openstack-nova-consoleauth.service openstack-nova-scheduler.service \
  openstack-nova-conductor.service openstack-nova-novncproxy.service

cp /usr/lib/sysctl.d/50-default.conf /usr/lib/sysctl.d/50-default.conf.bak
echo "net.ipv4.ip_forward = 1" >>/usr/lib/sysctl.d/50-default.conf
sysctl -p ###如不生效重启一下OS

#内部虚拟机增路由
ip route add default via 192.168.56.2

vim /etc/sysconfig/static-routes
# add route define
any net 0.0.0.0/0 gw 192.168.56.2

#MySQL调优
[mysqld]
default-storage-engine=innodb
innodb_buffer_pool_size= 512M #2G

#系统参数的优化
vim /etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft core ulimit
* hard core ulimit


openstack flavor create FLAVOR_NAME --id FLAVOR_ID \
    --ram RAM_IN_MB --disk ROOT_DISK_IN_GB --vcpus NUMBER_OF_VCPUS

openstack flavor create m1.tiny --id 1 \
    --ram 512 --disk 1 --vcpus 1

openstack flavor create m1.small --id 2 \
    --ram 2048 --disk 20 --vcpus 1

openstack flavor create m1.medium --id 3 \
    --ram 4096 --disk 40 --vcpus 2

openstack flavor create m1.large --id 4 \
    --ram 8192 --disk 80 --vcpus 4

openstack flavor create m1.xlarge --id 5 \
    --ram 16384 --disk 160 --vcpus 8
	
openstack server create --image

Flavor	  VCPUs	  Disk (in GB)	  RAM (in MB)
m1.tiny	  1	      1               512
m1.small	1     	20              2048
m1.medium	2	      40              4096
m1.large	4       80              8192
m1.xlarge	8	      160             16384

sed -i 's/inter 2000 rise 2 fall 5/inter 10000 rise 2 fall 1/' /etc/haproxy/haproxy.cfg
tail -f /var/log/nova/nova-api.log|grep -v "OPTIONS /"

openstack image create "cirros" \
  --file cirros-0.4.0-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --public
  
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'innobase' WITH GRANT OPTION;
flush privileges;

wget https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
yum install kernel-devel -y
yum groupinstall "Development tools" -y
yum install VirtualBox-5.2 -y